<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui">
      
    <ui:composition template="/new-template/template-crud.xhtml">
    	
    	<ui:define name="tituloPagina">
    		<h:outputText value="Transações :: Controle de Acesso :: SEDUC" />
    	</ui:define>
    	
    	<ui:define name="parametros">
    	   <ui:param name="bean" value="#{transacaoBean}" />
    	</ui:define>
    	
    	<ui:define name="tituloFieldSetFiltro">
		   <h:outputText value="&nbsp; Pesquisa de Transações &nbsp;" />
		</ui:define>
		
		<ui:define name="camposFiltro">
			<h:panelGrid columns="2" columnClasses="colunaBusca">
				  		
				 <h:outputLabel value="Nome: "/>
				 <h:inputText id="inputText" value="#{transacaoBean.entitySearch.descricao}" 
							  size="50" maxlength="50"	>
					<f:converter converterId="converterStringVazia"/>
					<f:validator validatorId="textoValidator"/>
				 </h:inputText>	
				 
				<h:outputLabel value="Módulo: "/>
				<h:selectOneMenu id="selectModuloSeach"
							     style="width:auto"
								 label="Módulo"
								 converter="converterEntity"
							     value="#{transacaoBean.entitySearch.modulo}">
					<f:selectItem itemLabel="Selecione um Módulo" />	
					<f:selectItems value="#{moduloBean.allSelectItem}"/>						
				</h:selectOneMenu>				  	
			</h:panelGrid>
		</ui:define>
		
		<ui:define name="tituloPainel">
		  <ui:param name="tituloPainel" value="Transação" />
		</ui:define>
		
		<ui:define name="resultFiltro">
			<p:dataTable align="center" 
   						 width="600px" 
   						 id="transacoes"
   						 rows="10"
   						 pageLinks="3"
   						 paginatorAlwaysVisible="false"
   						 emptyMessage="Nenhuma Transação foi encontrada."
   						 value="#{transacaoBean.resultSearch}" 
       					 var="transacao" 
       					 paginator="#{transacaoBean.resultSearch.rowCount > 0}"
       					 paginatorPosition="bottom"
       					 rowStyleClass="bgLinha1,bgLinha2">
       					
       						<p:column headerText="" style="width:60px; text-align:center;">
       							<div class="colunaAcao">					    			
									<h:commandButton style="border:none;" 
													 id="cmdUpd" 
													 image="#{resource['img:ico_edit.gif']}"
													 actionListener="#{transacaoBean.prepareUpdate}">
										  <p:ajax update="painelGlobal" />
									</h:commandButton>
								</div>
       						</p:column>
       						
       						<p:column headerText="ID" style="text-align:center;">
       							<h:outputText value="#{transacao.id}" />
       						</p:column>
       						
       						<p:column headerText="Nome" style="text-align:left;" >
       							<h:outputText value="#{transacao.descricao}" />
       						</p:column>
       						
       						<p:column headerText="Label" style="text-align:left;" >
       							<h:outputText value="#{transacao.label}" />
       						</p:column>

       						<p:column style="width:60px; text-align:center;">
       							<f:facet name="header">
       								<h:selectBooleanCheckbox styleClass="ui-checkBoxMain" rendered="#{transacaoBean.resultSearch.rowCount > 0}" />
       							</f:facet>
       							<h:selectBooleanCheckbox styleClass="ui-checkBox" valueChangeListener="#{transacaoBean.select}" />
       						</p:column>
       						
				 	</p:dataTable> 
		</ui:define>
		
		<ui:define name="tituloFieldSetInsert">
		  <h:outputLabel value="&nbsp; Cadastro de Transações" />
		</ui:define>
		
		<ui:define name="camposInsert">
			<h:panelGrid columns="2" columnClasses="colunaBusca" >
				  		
			  <h:outputLabel value="Nome: *"/>
			  <h:inputText required="true" 
						   label="Nome"
						   value="#{transacaoBean.entity.descricao}" 
						   maxlength="50" 
						   size="40">						
			  </h:inputText>	
			  
			  <h:outputLabel value="Label *"/>
			  <h:inputText required="true" 
						   label="Label"
						   value="#{transacaoBean.entity.label}" 
						   maxlength="50" 
						   size="40">						
			  </h:inputText>	

			  
			 <h:outputLabel value="Módulos:"/>
		     <p:pickList value="#{transacaoBean.moduloList}" 
		     			 addLabel="Adicionar"
		     			 addAllLabel="Adicionar Todos"
		     			 removeLabel="Remover"
		     			 removeAllLabel="Remover Todos"   
		                 var="modulo"  
		                 itemLabel="#{modulo.descricao}"  
		                 itemValue="#{modulo}"
		                 converter="converterEntity" >
			</p:pickList>               
		   
			  
		  </h:panelGrid>
		</ui:define>
		
    </ui:composition>
</html>